function checkoutContr($scope,$http) {
    $scope.factory("cart", function(){
        var cartData = [];
        return{
            addProduct:function(id,name,price){
                var addedToExistingItem = false;
                for(var i=0; i<cartData.length;i++){
                    if(cartData[i].id == id){
                        cartData[i].count++;
                        addedToExistingItem = true;
                        break;
                    }
                }
                if(!addedToExistingItem){
                    cartData.push({
                        count:1,id:id,price:price,name:name
                    });
                }
            },
            removeProduct:function(id){
                for(var i=0;i<cartData.length;i++){
                    if(cartData[i].id == id){
                        cartData.splice(i,1);
                        break;
                    }
                }
            },
            getProducts:function(){
                return cartData;
            }
        }
    });

    $scope.cartList = function($scope, cart){
        $scope.cartData = cart.getProducts();

        $scope.total=function(){
            var total = 0;
            for(var i=0;i<$scope.cartData.length;i++){
                total += ($scope.cartData[i].price * $scope.cartData[i].count);
            }
            return total;
        }
        $scope.remove = function(id){
            cart.removeProduct(id);
        }
        

    }












}